class PeopleService {
  /**
   * 
   * @param {ng.IHttpService} $http 
   */
  constructor($http) {
    this.$http = $http;
  }

  async getAllPeople() {
    console.log("call getAllPeople()");
    const resp = await this.$http
      .get("//localhost:5327/people", { cache: true });
    return resp.data;
  }
  async getPerson(id) {
    console.log("call getPerson(",id,")");

    function personMatchesParam(person) {
      return person.id === id;
    }

    const people = await this.getAllPeople();
    return people.find(personMatchesParam);
  }
}
angular.module("hello").service(
  "$people",
  PeopleService
);
